//
//  KZEveryDayCell.m
//  xiaorizi
//
//  Created by kun on 15/10/24.
//  Copyright © 2015年 origin. All rights reserved.
//

#import "KZEveryDayCell.h"
#import "NSString+Frame.h"
#import "UIButton+WebCache.h"

@interface KZEveryDayCell ()
@property (weak, nonatomic) IBOutlet UILabel *feeltitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UIButton *eventsButton;
@property (weak, nonatomic) IBOutlet UIButton *themesButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *themesConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *eventsConstraint;

@end


@implementation KZEveryDayCell



-(void)setModel:(EveryDayModel *)model
{
#warning 2 没有解决 在点击按钮高粱状态图片闪的情况？
    _model = model;
    
    CGFloat themesH ;
    CGFloat eventsH ;
    
    if(_model.title != nil)
    {
        _feeltitleLabel.text = model.feeltitle;
        
        _titleLabel.text = model.title;
        _addressLabel.text = model.address;
    
        [self.eventsButton sd_setBackgroundImageWithURL:[NSURL URLWithString:model.imgs] forState:UIControlStateNormal];
       
        eventsH = 200;
    }
    
    if(_model.themes != nil)
    {
        themesH = 200;
        DvdModel *model = _model.themes;
        
        [self.themesButton sd_setBackgroundImageWithURL:[NSURL URLWithString:model.img] forState:UIControlStateNormal];
        
        [self.themesButton setTitle:model.titles forState:UIControlStateNormal];
    }
    
    //1添加约束控制
    self.eventsConstraint.constant = eventsH;
    self.themesConstraint.constant = themesH;
    
    [self updateConstraintsIfNeeded];
}


//执行按钮点击事件
- (IBAction)imgButtonClicked:(id)sender {
    
     DvdModel *model = _model.themes;
    
    if(self.imgButtonBlock)
    {
        self.imgButtonBlock(self,model.themeurl);
    }
}
- (IBAction)eventsButtonClicked:(id)sender {
    if(self.eventsButton)
    {
        self.eventsButtonBlock(self,_model);
    }
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
